package br.utfpr.edu.bean;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "ANALISE")
public class Analise implements Serializable, Comparable{
	

	private static final long serialVersionUID = 123424234L;
	@Id
    @Column(name ="ID")
    @GeneratedValue(strategy=GenerationType.IDENTITY)
	private String id;
	@JoinColumn(name="PROJETO",referencedColumnName="PR_ID")
	@ManyToOne(optional = false)
	private Projeto projeto;
	@Column(name ="CLASSE")
	private String classe;
	@JoinColumn(name="FAMILIA",referencedColumnName="FAID")
	@ManyToOne(optional = false)
	private Familia familia;
	@Column(name ="INICIO")
	private Integer inicio;
	@Column(name ="FIM")
	private Integer fim;
	@Column(name ="COMPLEMENTAR")
	private String complementar;
	@JoinColumn(name="GENE",referencedColumnName="ID")
	@ManyToOne(optional = false)
	private Gene gene;
	@Transient
	private boolean marcar;
	@Column(name = "FITA")
	private String fita;
	@Column(name = "LOCALIZACAO")
	private String localizacao;
	
	public Analise(){
		projeto = new Projeto();
		familia = new Familia();
		gene = new Gene();
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public Projeto getProjeto() {
		return projeto;
	}
	public void setProjeto(Projeto projeto) {
		this.projeto = projeto;
	}
	public String getClasse() {
		return classe;
	}
	public void setClasse(String classe) {
		this.classe = classe;
	}
	public Familia getFamilia() {
		return familia;
	}
	public void setFamilia(Familia familia) {
		this.familia = familia;
	}
	
	public Integer getInicio() {
		return inicio;
	}

	public void setInicio(Integer inicio) {
		this.inicio = inicio;
	}

	public Integer getFim() {
		return fim;
	}

	public void setFim(Integer fim) {
		this.fim = fim;
	}

	public String getComplementar() {
		return complementar;
	}

	public void setComplementar(String complementar) {
		this.complementar = complementar;
	}

	public Gene getGene() {
		return gene;
	}

	public void setGene(Gene gene) {
		this.gene = gene;
	}

	public boolean getMarcar() {
		return marcar;
	}

	public void setMarcar(boolean marcar) {
		this.marcar = marcar;
	}

	@Override
	public String toString() {
		return id;
	}

	public String getFita() {
		return fita;
	}

	public void setFita(String fita) {
		this.fita = fita;
	}
	
	public String getLocalizacao() {
		return localizacao;
	}

	public void setLocalizacao(String localizacao) {
		this.localizacao = localizacao;
	}

	@Override
	public int hashCode() {
		final int prime = 356;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Analise other = (Analise) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@Override
	public int compareTo(Object o) {
		Analise e = (Analise)o;  
        return this.classe.compareTo(e.getClasse());
	}
	
}
